﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class my_attack : MonoBehaviour
{
    public int damage;
    void Start()
    {
    }

    void Update()
    {
    }




    void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.name.Equals("ga_body") && transform.parent.gameObject.GetComponent<my>().get_attacking() == 1)
        //if 用于判定伤害区域&&防止同一次攻击造成多次伤害
        {
            transform.parent.gameObject.GetComponent<my>().set_attacking();
            //造成一次攻击之后修改attacking标志位，防止二次伤害
            //other.SendMessage()
            other.transform.parent.SendMessage("TakeDamage",20);    
        //other.transform.parent.GetComponent<sc>().TakeDamage(damage);
            //找到受伤的角色，调用收到攻击的函数。
        }
    }
}
